package com.zenchn.dynamic;

import static com.zenchn.dynamic.TSysOauthClientDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TSysOauthClient;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TSysOauthClientDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    BasicColumn[] selectList = BasicColumn.columnList(clientId, clientName, createTime, grantType, clientSecret, memo);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TSysOauthClient> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TSysOauthClient> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TSysOauthClientResult")
    Optional<TSysOauthClient> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TSysOauthClientResult", value = {
        @Result(column="client_id", property="clientId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="client_name", property="clientName", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="grant_type", property="grantType", jdbcType=JdbcType.VARCHAR),
        @Result(column="client_secret", property="clientSecret", jdbcType=JdbcType.VARCHAR),
        @Result(column="memo", property="memo", jdbcType=JdbcType.VARCHAR)
    })
    List<TSysOauthClient> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TSysOauthClient, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TSysOauthClient, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default int deleteByPrimaryKey(String clientId_) {
        return delete(c -> 
            c.where(clientId, isEqualTo(clientId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default int insert(TSysOauthClient record) {
        return MyBatis3Utils.insert(this::insert, record, TSysOauthClient, c ->
            c.map(clientId).toProperty("clientId")
            .map(clientName).toProperty("clientName")
            .map(createTime).toProperty("createTime")
            .map(grantType).toProperty("grantType")
            .map(clientSecret).toProperty("clientSecret")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default int insertMultiple(Collection<TSysOauthClient> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TSysOauthClient, c ->
            c.map(clientId).toProperty("clientId")
            .map(clientName).toProperty("clientName")
            .map(createTime).toProperty("createTime")
            .map(grantType).toProperty("grantType")
            .map(clientSecret).toProperty("clientSecret")
            .map(memo).toProperty("memo")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default int insertSelective(TSysOauthClient record) {
        return MyBatis3Utils.insert(this::insert, record, TSysOauthClient, c ->
            c.map(clientId).toPropertyWhenPresent("clientId", record::getClientId)
            .map(clientName).toPropertyWhenPresent("clientName", record::getClientName)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(grantType).toPropertyWhenPresent("grantType", record::getGrantType)
            .map(clientSecret).toPropertyWhenPresent("clientSecret", record::getClientSecret)
            .map(memo).toPropertyWhenPresent("memo", record::getMemo)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default Optional<TSysOauthClient> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TSysOauthClient, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default List<TSysOauthClient> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TSysOauthClient, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default List<TSysOauthClient> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TSysOauthClient, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default Optional<TSysOauthClient> selectByPrimaryKey(String clientId_) {
        return selectOne(c ->
            c.where(clientId, isEqualTo(clientId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TSysOauthClient, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    static UpdateDSL<UpdateModel> updateAllColumns(TSysOauthClient record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(clientId).equalTo(record::getClientId)
                .set(clientName).equalTo(record::getClientName)
                .set(createTime).equalTo(record::getCreateTime)
                .set(grantType).equalTo(record::getGrantType)
                .set(clientSecret).equalTo(record::getClientSecret)
                .set(memo).equalTo(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TSysOauthClient record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(clientId).equalToWhenPresent(record::getClientId)
                .set(clientName).equalToWhenPresent(record::getClientName)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(grantType).equalToWhenPresent(record::getGrantType)
                .set(clientSecret).equalToWhenPresent(record::getClientSecret)
                .set(memo).equalToWhenPresent(record::getMemo);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default int updateByPrimaryKey(TSysOauthClient record) {
        return update(c ->
            c.set(clientName).equalTo(record::getClientName)
            .set(createTime).equalTo(record::getCreateTime)
            .set(grantType).equalTo(record::getGrantType)
            .set(clientSecret).equalTo(record::getClientSecret)
            .set(memo).equalTo(record::getMemo)
            .where(clientId, isEqualTo(record::getClientId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_oauth_client")
    default int updateByPrimaryKeySelective(TSysOauthClient record) {
        return update(c ->
            c.set(clientName).equalToWhenPresent(record::getClientName)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(grantType).equalToWhenPresent(record::getGrantType)
            .set(clientSecret).equalToWhenPresent(record::getClientSecret)
            .set(memo).equalToWhenPresent(record::getMemo)
            .where(clientId, isEqualTo(record::getClientId))
        );
    }
}